WARNING: This program does not work the way we want it to! It has a logic error and we need to fix it!

RULE: When you open a file in write mode and write to it, you overwrite everything inside the file. If you'd like to add to the end of a file, you can use append mode, specified with an "a".

  • Click Run. Notice that when we print our shopping list a second time, we only see "pickles".
  • Change the "w" in the open() command to "a", so we don't overwrite our file!

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)